package client;

import com.fasterxml.jackson.annotation.JsonProperty;
import server.maps.AnimatedMapleMapObject;
import server.maps.MapleMapObjectType;
import server.movement.LifeMovement;
import server.movement.LifeMovementFragment;
import tools.packet.FamiliarPacket;

import java.util.List;

public class MonsterFamiliarObj extends AnimatedMapleMapObject {

    private MonsterFamiliar familiar;

    public MonsterFamiliarObj(@JsonProperty("familiar") MonsterFamiliar familiar) {
        this.familiar = familiar;
    }

    public MonsterFamiliar getFamiliar() {
        return familiar;
    }

    @Override
    public void sendSpawnData(MapleClient client) {
        client.announce(FamiliarPacket.spawnFamiliar(familiar));
    }

    @Override
    public void sendDestroyData(MapleClient client) {
        client.announce(FamiliarPacket.removeFamiliar(familiar.getCharacterid()));
    }

    @Override
    public MapleMapObjectType getType() {
        return MapleMapObjectType.FAMILIAR;
    }

    public final void updatePosition(List<LifeMovementFragment> movement) {
        for (LifeMovementFragment move : movement) {
            if ((move instanceof LifeMovement)) { // && ((move instanceof StaticLifeMovement))) {
                setStance(((LifeMovement) move).getNewstate()); // setFh(((StaticLifeMovement) move).getUnk());
            }
        }
    }
}
